# -*- coding: utf-8 -*-
"""
@ Created on 2024-06-14 12:23
---------
@summary: FastAPI应用主入口
---------
@author: Lsaiah
"""

import uvicorn
from core.server import InitializeApp
from app.system.auth import auth_router
from app.system.user import user_router
from app.system.dict.api.dict_type_api import dict_type_router
from app.system.dict.api.dict_item_api import dict_item_router
from settings import settings
from log import logger

# 创建FastAPI应用
app_init = InitializeApp()

# 包含路由
app_init.include_router(auth_router, prefix="/api")
app_init.include_router(user_router, prefix="/api")
app_init.include_router(dict_type_router, prefix="/api")
app_init.include_router(dict_item_router, prefix="/api")

# 获取应用实例
app = app_init.get_app()


if __name__ == "__main__":
    logger.info("启动FastAPI应用...")
    uvicorn.run(
        "main:app",
        host=settings.host,
        port=settings.port,
        reload=settings.reload,
        workers=settings.workers,
        log_level=settings.LOG_LEVEL.lower()
    )